<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="ISO-8859-1"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title><spring:message code="data.ship.title"/></title>
</head>
<body>
<a href="<c:url value="?lang=en"/>">en</a>
<a href="<c:url value="?lang=ru"/> ">ru</a>
<br>
<a href="../data.htm"><spring:message code="label.dataManager"/></a>


<h2><spring:message code="data.ship.title"/></h2>

<form:form method="post" action="ships/add.htm" commandName="ship">
	<table>
		<tr>
			<td><form:label path="name">
				<spring:message code="data.ship.name"/>
			</form:label></td>
			<td><form:input path="name"/></td>
		</tr>
		<tr>
			<td><form:label path="shipType.id">
				<spring:message code="data.ship.shipType"/>
			</form:label></td>
				<td><form:select path="shipType.id">
						<option></option>
						<form:options items="${shipTypes}" itemValue="id" itemLabel="shipType" />
					</form:select>
				</td>
		</tr>
		<tr>
			<td><form:label path="length">
				<spring:message code="data.ship.length"/>
			</form:label></td>
			<td><form:input path="length"/></td>
		</tr>
		<tr>
			<td colspan="2"><input type="submit"
				value="<spring:message code="submit.add"/>" /></td>
		</tr>
	</table>
</form:form>

<h3><spring:message code="data.ship.ships" /></h3>
<c:if test="${!empty shipList}">
	<table class="data">
		<tr>
			<th><spring:message code="data.ship.name"/></th>
			<th><spring:message code="data.ship.shipType"/></th>
			<th><spring:message code="data.ship.length"/></th>
			<th>&nbsp;</th>
		</tr>
		<c:forEach items="${shipList}" var="item">
			<tr>
				<td>${item.name}</td>
				<td>${item.shipType.shipType}</td>
				<td>${item.length}</td>
				<td><a href="ships/delete/${item.id}.htm"><spring:message code="submit.delete"/></a></td>
			</tr>
		</c:forEach>
	</table>
</c:if>

</body>
</html>